home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 39 / PCGAMER39.bin / games / amber / amberhub.dxr / 00023_demo handlers.ls < prev    next >
Encoding:
Text File  |  1996-11-08  |  4.9 KB  |  173 lines

  1. on keytest
  2.   repeat with i = 1 to 50
  3.     put the lastKey
  4.     updateStage()
  5.   end repeat
  6. end
  7.  
  8. on enterOffice
  9.   global oStoryteller
  10.   newGame(oStoryteller)
  11. end
  12.  
  13. on keyDown
  14.   global oStoryteller
  15.   put "keydown " & random(23)
  16.   if the number of menus > 0 then
  17.     put "menu count > 0"
  18.     pass()
  19.     exit
  20.   end if
  21.   set foo to the key
  22.   put foo
  23.   if "01234567" contains foo then
  24.     do("set the soundLevel to " & foo)
  25.   end if
  26.   if "XxQq" contains the key then
  27.     set the trace to 1
  28.     quitGame(oStoryteller)
  29.   end if
  30.   dontPassEvent()
  31. end
  32.  
  33. on fadeOutTransit
  34.   if the frameTransition = 0 then
  35.     repeat with fadeFactor = 30.0 down to 0.0
  36.       repeat with i = 1 to 4
  37.         set the volume of sound i to float(the volume of sound i) * (fadeFactor / 30.0)
  38.       end repeat
  39.       wait(5)
  40.       updateStage()
  41.     end repeat
  42.   else
  43.     repeat with i = 1 to 4
  44.       set the volume of sound i to 0
  45.     end repeat
  46.     updateStage()
  47.   end if
  48. end
  49.  
  50. on grabberInit
  51.   global oGrabber, gRippleSize, gCPU, gHorsepower
  52.   set totalRAM to the memorysize / 1024
  53.   if (totalRAM >= 8000) and (gHorsepower <> #low) then
  54.     preLoadCast(2428, 2451)
  55.     set gRippleSize to #large
  56.   else
  57.     if totalRAM >= 6000 then
  58.       preLoadCast(2453, 2472)
  59.       set gRippleSize to #small
  60.     else
  61.       return #lowRAM
  62.       exit
  63.     end if
  64.   end if
  65.   return #OK
  66. end
  67.  
  68. on ripple
  69.   global oGrabber, gLastRipple, gRippleSize, gOriginPoint
  70.   if the ticks < (gLastRipple + (3 * 60)) then
  71.     exit
  72.   end if
  73.   if voidp(gRippleSize) then
  74.     set rippleStatus to grabberInit()
  75.     if rippleStatus <> #OK then
  76.       exit
  77.     end if
  78.   end if
  79.   set rippleSprite to 37
  80.   puppetSprite(rippleSprite, 1)
  81.   set the ink of sprite rippleSprite to 9
  82.   if gRippleSize = #small then
  83.     set firstCastPos to 2453
  84.     set lastCastPos to 2471
  85.     set grabWidth to 96
  86.     set grabHeight to 96
  87.     set rippleTempo to 2
  88.   else
  89.     set firstCastPos to 2428
  90.     set lastCastPos to 2450
  91.     set grabWidth to 160
  92.     set grabHeight to 170
  93.     set rippleTempo to 1
  94.   end if
  95.   set clipRegion to rect(the stageLeft + 112, the stageTop + 80, the stageLeft + 534, the stageTop + 356)
  96.   set leftOffset to random(the right of clipRegion - the left of clipRegion - (grabWidth + 2))
  97.   set leftEdge to the left of clipRegion + leftOffset
  98.   set topOffset to random(the bottom of clipRegion - the top of clipRegion - (grabWidth - 2))
  99.   set topEdge to the top of clipRegion + topOffset
  100.   set errCode to ScreenToClipboard(leftEdge, topEdge, leftEdge + grabWidth, topEdge + grabHeight)
  101.   if errCode = "OK" then
  102.     alert("errcode = " & errCode)
  103.     exit
  104.   end if
  105.   set leftEdge to leftEdge - the stageLeft
  106.   set topEdge to topEdge - the stageTop
  107.   set the loc of sprite rippleSprite to point(leftEdge + (grabWidth / 2), topEdge + (grabHeight / 2))
  108.   set the loc of sprite rippleSprite to the loc of sprite rippleSprite + point(1, 1)
  109.   pasteClipBoardInto(member firstCastPos)
  110.   set the castNum of sprite rippleSprite to firstCastPos
  111.   set newPos to firstCastPos + 2
  112.   updateStage()
  113.   repeat while (newPos <= lastCastPos) and not (the commandDown)
  114.     wait(rippleTempo)
  115.     move(cast (newPos - 2), newPos)
  116.     set the castNum of sprite rippleSprite to newPos
  117.     set newPos to newPos + 2
  118.     updateStage()
  119.   end repeat
  120.   move(cast lastCastPos, firstCastPos)
  121.   set the loc of sprite rippleSprite to point(-1000, -1000) + gOriginPoint
  122.   set gLastRipple to the ticks
  123. end
  124.  
  125. on rippleWord maskSeries
  126.   global oGrabber, gRippleSize, gOriginPoint, gLastRipple
  127.   if the ticks < (gLastRipple + 60) then
  128.     exit
  129.   end if
  130.   if voidp(gRippleSize) then
  131.     set rippleStatus to grabberInit()
  132.     put "rippleStatus = " & rippleStatus
  133.     if rippleStatus <> #OK then
  134.       exit
  135.     end if
  136.   end if
  137.   set rippleSprite to 37
  138.   puppetSprite(rippleSprite, 1)
  139.   set the ink of sprite rippleSprite to 9
  140.   if maskSeries = #notTheEnd then
  141.     set firstCastPos to 200
  142.     set lastCastPos to 214
  143.     set leftEdge to 124
  144.     set topEdge to 160
  145.     set grabWidth to 392
  146.     set grabHeight to 164
  147.     set rippleTempo to 2
  148.   end if
  149.   updateStage()
  150.   set errCode to ScreenToClipboard(leftEdge, topEdge, leftEdge + grabWidth, topEdge + grabHeight)
  151.   if errCode = "OK" then
  152.     alert("errcode = " & errCode)
  153.     exit
  154.   end if
  155.   set leftEdge to leftEdge - the stageLeft
  156.   set topEdge to topEdge - the stageTop
  157.   set the loc of sprite rippleSprite to point(leftEdge + (grabWidth / 2), topEdge + (grabHeight / 2))
  158.   set the loc of sprite rippleSprite to the loc of sprite rippleSprite + point(1, 1)
  159.   pasteClipBoardInto(member firstCastPos)
  160.   set the castNum of sprite rippleSprite to firstCastPos
  161.   set newPos to firstCastPos + 2
  162.   updateStage()
  163.   repeat while (newPos <= lastCastPos) and not (the commandDown)
  164.     wait(rippleTempo)
  165.     move(cast (newPos - 2), newPos)
  166.     set the castNum of sprite rippleSprite to newPos
  167.     set newPos to newPos + 2
  168.     updateStage()
  169.   end repeat
  170.   move(cast lastCastPos, firstCastPos)
  171.   set the loc of sprite rippleSprite to point(-1000, -1000) + gOriginPoint
  172. end
  173.